home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Dreamweaver 3 / Configuration / Inspectors / _pi_common.js next >
Encoding:
Text File  |  1999-12-01  |  3.8 KB  |  141 lines

  1.  
  2.  
  3.  
  4. ////////////////////////////////////////////////////////////////////////////////
  5. //
  6. //    Function: docBase
  7. //
  8. //    Returns the base path for the current document.
  9. //
  10. ////////////////////////////////////////////////////////////////////////////////
  11. function docBase()
  12. {
  13.     var docURL;
  14.     var docBase;
  15.     var    index    = 0;
  16.  
  17.     docURL = dreamweaver.getDocumentPath("DOCUMENT");
  18.     if ( "" == docURL )
  19.         return "";
  20.  
  21.     index = docURL.lastIndexOf('/');
  22.     if ( -1 == index )
  23.         return "";
  24.     
  25.     return docURL.substring(0, index);
  26. } // function docBase()
  27.  
  28. ////////////////////////////////////////////////////////////////////////////////
  29. //
  30. //    Function: findObject
  31. //
  32. //    Returns the named object.
  33. //
  34. ////////////////////////////////////////////////////////////////////////////////
  35. function findObject(objName,  parentObj)  
  36. {
  37.     var    curObj    = "";
  38.     var    found    = false;
  39.     var    i        = 0;
  40.     var NS        = (navigator.appName.indexOf("Netscape") != -1);
  41.     var tempObj    = ""
  42.     
  43.  
  44.     if (!NS && document.all) 
  45.         curObj = document.all[objName]; //IE4
  46.     else 
  47.     {
  48.         parentObj = (parentObj != null)? parentObj.document : document;
  49.  
  50.         if (parentObj[objName] != null) 
  51.             curObj = parentObj[objName]; //at top level
  52.         else 
  53.         { 
  54.             if (parentObj.forms) for (i=0; i<parentObj.forms.length; i++)
  55.             {  
  56.                 //search level for form object
  57.                 if (parentObj.forms[i][objName]) 
  58.                 {
  59.                     curObj = parentObj.forms[i][objName];
  60.                     found = true; break;
  61.                 } 
  62.             } // if (parentObj.forms) for (i=0; i<parentObj.forms.length; i++)
  63.  
  64.             if (!found && NS && parentObj.layers && parentObj.layers.length > 0) 
  65.             {
  66.                 parentObj = parentObj.layers;
  67.                 for (i=0; i<parentObj.length; i++) 
  68.                 { //else search for child layers
  69.                     tempObj = findObject(objName,parentObj[i]); //recurse
  70.                     if (tempObj) 
  71.                     { 
  72.                         curObj = tempObj; break;
  73.                     } //if found, done
  74.                 } 
  75.             } // if (!found && NS && parentObj.layers && parentObj.layers.length > 0)
  76.         } // if (parentObj[objName] != null)  else 
  77.     } // if (!NS && document.all) else
  78.   
  79.     return curObj;
  80. } // function findObject(objName,  parentObj)
  81.  
  82.  
  83. ////////////////////////////////////////////////////////////////////////////////
  84. //
  85. //    Function: showHideTranslated
  86. //
  87. //    Returns the selected object.  Note:  This function does not take into
  88. //    account noncontiguous selections, or selections inside a table where there
  89. //    are more than two indices.
  90. //
  91. ////////////////////////////////////////////////////////////////////////////////
  92. function getSelectedObj() 
  93. {
  94.   var    selArr    = dreamweaver.getSelection();
  95.   return dreamweaver.offsetsToNode(selArr[0],selArr[1]);
  96. } // function getSelectedObj()
  97.  
  98. ////////////////////////////////////////////////////////////////////////////////
  99. //
  100. //    Function: showHideTranslated
  101. //
  102. //    Shows or hides the translated attribute button layer of a PI according to
  103. //    whether or not the object being inspected has translated attributes.
  104. //
  105. ////////////////////////////////////////////////////////////////////////////////
  106. function showHideTranslated()
  107. {
  108.     var theObj = getSelectedObj();
  109.     if (!theObj.tagName)
  110.         return;
  111.     
  112.     if ( theObj.hasTranslatedAttributes() )
  113.     {    
  114.         //alert('show');
  115.         document.layers['tButtonSpan'].visibility = 'visible';
  116.         // Show the layer
  117.     }
  118.     else
  119.     {
  120.     //    alert('hide');
  121.         document.layers['tButtonSpan'].visibility = 'hidden';
  122.         // Hide the layer
  123.     }
  124.  
  125. } // function showHideTranslated( theObj, theLayer )
  126.  
  127. ////////////////////////////////////////////////////////////////////////////////
  128. //
  129. //    Function: launchQuickTagEditor
  130. //
  131. //    Displays the quick tag editor.  If being called because the translated
  132. //    attributes icon was clicked, then the caller should set forTranslationIcon
  133. //    to true.
  134. //
  135. ////////////////////////////////////////////////////////////////////////////////
  136. function launchQuickTagEditor( forTranslationIcon )
  137. {
  138.     // Currently, forTranslationIcon is ignored.
  139.     dw.showQuickTagEditor("near mouse");
  140. } // function launchQuickTagEditor( forTranslationIcon )
  141.